<%
# 
# Copyright (C) 2006  Warren Konkel and Bounty Source, Inc.
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# 

  # build out our JS string
  counter = 0
  return_str = "insertafter=$('tr#{params['parent_id']}');"

  # sort them by directories, then files, then alphabetically
  entries.sort{ |a,b| if a[:is_dir] && !b[:is_dir]; -1; elsif !a[:is_dir] && b[:is_dir]; 1; else; a[:name] <=> b[:name]; end;  }.each { |entry|
    divid = params['parent_id'] + '_' + (counter = counter + 1).to_s
    return_str << "insertafter=createNewTableRow('#{$bs_svn_browser[:url_base]}', '#{@rev}', insertafter,'#{divid}',#{@load_path.length},'#{escape_javascript(entry[:name])}','#{entry[:created_revision]}', '#{File.join(@load_path + [entry[:name]])}',#{entry[:is_dir] ? 'true' : 'false'},'#{entry[:filesize] >= 0 ? escape_javascript(number_to_human_size(entry[:filesize])) : ''}','#{escape_javascript(time_ago_in_words(entry[:date]))}','#{escape_javascript((format_user(entry[:author]) || '') + ": " + truncate(entry[:log],50))}');"
  }
  return_str << "finishLoadingNewRows('#{params['parent_id']}');"
%><%=return_str%>
